<template>
  <BaseDialog
    ref="baseDialog"
    :title="'输入原因'"
    @confrim="confrim"
    @cancel="close"
  >
    <BaseForm
      labelWidth="150px"
      :fromIems="fromIems"
      :size="'medium'"
      ref="BaseForm"
      @submit="submit"
      @edit="edit"
    ></BaseForm>
  </BaseDialog>
</template>

<script>
import { Message } from "element-ui";
import { approval } from "@/api/review";
export default {
  name: "add",
  data() {
    return {
      title: "",
      orgCode: null,
      fromIems: [
        {
          valueType: "input",
          label: "备注说明",
          dataIndex: "note",
          type: "textarea",
        },
      ],
      isEdit: false,
    };
  },
  methods: {
    open(row) {
      row ? (this.isEdit = true) : (this.isEdit = false);
      this.$refs.baseDialog.open();
      this.$nextTick(() => {
        if (row) {
            this.orgCode = row.orgCode
          for (var k in row) {
            this.$set(this.$refs.BaseForm.form, k, row[k]);
          }
        } else {
          this.$refs.BaseForm.form = {};
        }
      });
    },

    close() {
      this.$refs.baseDialog.close();
      this.$refs.BaseForm.rest();
    },
    confrim() {
      if (this.isEdit) {
        this.$refs.BaseForm.edit();
      } else {
        this.$refs.BaseForm.submit();
      }
    },
    async submit(data) {},
    async edit(data) {
      const res = await approval({
        note: data.note,
        orgCode: this.orgCode,
        result: -1,
      });
      if (!res.status) {
        this.$emit("success");
        Message.success("success");
        this.close();
      }
    },
  },
};
</script>

<style lang="scss" scoped></style>
